package com.xiaoliuzhi.android.uinput.jni;

public class AnalogInput {
	public static 	int width=1280;
	public static int height=720;
	public static boolean start=false;
	
	public static int xlast=0;
	public static int ylast=0;
	
	public static int LENGTH=12;
	static {
		System.loadLibrary("analoginput");
	}
	
	//public static void 
	
	/**
	 * 单击key
	 * @param code
	 */
	public static native void sendSingleButton(int code);
	
	/**
	 * 
	 * @param xValue
	 * @param yValue
	 * @param factor
	 */
	public static native void sendMouseMoveRel(int xValue,int yValue,int factor);
	
	/**
	 * ABS_X与ABS_Y
   	 * @param xValue
	 * @param yValue
	 */
	public static native void sendMouseMoveAbs(float xValue,float yValue,int factor);
	
	
	/**
	 * 
	 * @param xValue
	 * @param yValue
	 */
	public static native void sendSingleTouch(int xValue,int yValue);
	
	/**
	 *
	 */
	public static native void sendSync();
	
	/**
	 * 
	 * @param code
	 * @param value
	 */
	public static native void sendButtonSet(int code,int value);
	
	public static native int setupUinputDevice(int width,int height);
	
	public static native void colseUinputDevice();
	
	public native static void sendMouseWheel(int value) ;

	private static int lastKeycode=0;
	
	private static long lastTime=0;
	
	public static void setKeyClick(int keycode) {
		long curtime=System.currentTimeMillis();
		if((curtime-lastTime)>500||keycode!=lastKeycode){
			lastTime=curtime;
			lastKeycode=keycode;
		   sendSingleButton(keycode);
		}
	}


	
}
